import { toolsCarbonIndicatorApi } from '@/api'
import type { Template004ParamsType, DataTotalOrDetailsResult } from '@/api/modules/toolsCarbonIndicator'

export type { DataTotalOrDetailsResult }
export function useLoadData() {
  // const params = {
  //   pointId: 1,
  //   timeType: STORAGE_MODES.MONTH,
  //   dataTime: '2025-03',
  //   queryText: '11',
  //   isVirtually: 1 as 0 | 1,
  // }

  // toolsCarbonIndicatorApi.dataTotal(params)
  // toolsCarbonIndicatorApi.dataDetails(params)

  const totalData = ref<DataTotalOrDetailsResult>()
  const detailsData = ref<DataTotalOrDetailsResult>()

  async function dataTotal(params: Template004ParamsType) {
    const { data } = await toolsCarbonIndicatorApi.dataTotal(params)
    totalData.value = data
    return data
  }

  async function dataDetails(params: Template004ParamsType) {
    const { data } = await toolsCarbonIndicatorApi.dataDetails(params)
    detailsData.value = data
    return data
  }

  return {
    totalData,
    detailsData,
    dataTotal,
    dataDetails,
  }
}
